<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Grid Test</title>
<!-- css -->
<link id="fd_theme" href="../../styles/theme/aristo/theme.css" rel="stylesheet" type="text/css" />
<link href="../../styles/primeui-1.1-min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body{font-size: 12px}
</style>
<!-- lib -->
<script type="text/javascript" src="../../src/FDLib/FDLib.js"></script>
<script type="text/javascript" src="../../src/JsMap.js"></script>
<!-- app js -->
<script type="text/javascript" src="../theme.js"></script>
<script type="text/javascript" src="data.js"></script>
</head>
<body>
<h3>本功能可记住勾选状态,如:在第一页勾选后,点击下一页再返回到第一页依然勾选</h3>
<button onclick="reset()">重置</button>
<button onclick="getChecked()">getChecked</button>
<div id="grid"></div>
<br>
<div id="grid2"></div>

<script type="text/javascript">
FDLib.setDir('../../src/');
//FDLib.openDebug();

var grid,grid2;

FDLib.loadJs('FDGrid',function(){
	
	grid = new FDGrid({
		domId:'grid'
		,data:gridData
		,id:'id'
		,selectOption:{multiSelect:true,cache:true}
		,columns:[
			{text:"姓名",name:"username"}
			,{text:"联系地址",name:"addr"}
			,{text:"出生日期",name:"birthday"}
			,{text:"年龄",name:"age"}
		]
		// 操作列
		,actionButtons:[
   			{text:'修改',onclick:update}
   			,{text:'删除',onclick:del}
   		]
		// 每页大小下拉框选项,默认为10,20,30
		,pageSizeParam:[3,4,5]
	});
	
	grid2 = new FDGrid({
		domId:'grid2'
		,data:gridData
		,id:'id'
		,selectOption:{singleSelect:true,cache:true}
		,columns:[
			{text:"姓名",name:"username"}
			,{text:"联系地址",name:"addr"}
			,{text:"出生日期",name:"birthday"}
			,{text:"年龄",name:"age"}
		]
		// 操作列
		,actionButtons:[
   			{text:'修改',onclick:update}
   			,{text:'删除',onclick:del}
   		]
		,pageSize:5
		,pageSizeParam:[5,10,20]
	});
});

function update(rowData,rowIndex) {
	alert(rowIndex + " update: " + rowData.username);
}
function del(rowData,rowIndex) {
	alert(rowIndex + " del: " + rowData.username);
}
function reset() {
	grid.search();
	grid2.search();
}
function getChecked() {
	var rows = grid.getChecked();
	var ret = [];
	for(var i=0,len=rows.length;i<len;i++){
		ret.push(rows[i].id);
	}
	alert(ret)
	alert(grid2.getSelected().id)
}
</script>
</body>
</html>